import { Ajax, Config } from '../utils'
import Qs from 'querystring'
const { down_blob, unajax } = Ajax
const BASE_URL = Config.BaseUrl
const FILE_URL = Config.FileUrl

//上传文件
export const imageFile = (data)=>ax('FileService/UploadImageFile',data,'post',false);
export const wxShare = (url) => uajax('FileService/GetJsApiTicket',{url},'post')

const ax = (url,data={},type="post",bool=true)=>{
    if(bool){
        return Ajax(BASE_URL+url,Qs.stringify(data),type)
    }else{
        return Ajax(BASE_URL+url,data,type)
    }
}

const uajax = (url,data={},type="post",bool=true)=>{
    if(bool){
        return unajax(BASE_URL+url,Qs.stringify(data),type)
    }else{
        return unajax(BASE_URL+url,data,type)
    }
}


//下载到本地的Api
export const download = (url, onProgress)=>{
    if(onProgress){
        return down_blob(FILE_URL,url,onProgress)
    }else{
        return down_blob(FILE_URL,url)
    }
}